#ifndef EDITORMAIN_H
#define EDITORMAIN_H

#include <wx/filedlg.h>

#include "Input/Mouse.h"
#include "Input/Keyboard.h"
#include "Drawing/IDrawer.h"
#include "EditorCore/Tools/ITool.h"

#include "Documents/BodyDocument.h"

#include "EditorApp.h"
#include "BaseMainFrame.h"
#include "CoordsTransformer.h"
#include "PropertyGridEntityViewer.h"

class MainFrame: public BaseMainFrame
{
public:
	MainFrame( wxFrame *frame );
	~MainFrame();

private:
	virtual void OnNew( wxCommandEvent& event );
	virtual void OnOpen( wxCommandEvent& event );
	virtual void OnSave( wxCommandEvent& event );
	virtual void OnSaveAs( wxCommandEvent& event );
	virtual void OnClose( wxCommandEvent& event );
	virtual void OnQuit( wxCommandEvent& event );

	virtual void OnUndo( wxCommandEvent& event );
	virtual void OnRedo( wxCommandEvent& event );
	virtual void OnCut( wxCommandEvent& event );
	virtual void OnCopy( wxCommandEvent& event );
	virtual void OnPaste( wxCommandEvent& event );
	virtual void OnDelete( wxCommandEvent& event );

	virtual void OnAbout( wxCommandEvent& event );

	virtual void OnToolSelectSelected( wxCommandEvent& event );
	virtual void OnToolMoveSelected( wxCommandEvent& event );
	virtual void OnToolCreateCircle( wxCommandEvent& event );
	virtual void OnToolCreatePolygon( wxCommandEvent& event );

	virtual void OnWorkPanelPaint( wxPaintEvent& event );
	virtual void OnWorkPanelSize( wxSizeEvent& event );

	virtual void OnWorkPanelKeyDown( wxKeyEvent& event );
	virtual void OnWorkPanelKeyUp( wxKeyEvent& event );
	virtual void OnWorkPanelLmbDown( wxMouseEvent& event );
	virtual void OnWorkPanelLmbUp( wxMouseEvent& event );
	virtual void OnWorkPanelRmbDown( wxMouseEvent& event );
	virtual void OnWorkPanelRmbUp( wxMouseEvent& event );
	virtual void OnWorkPanelMouseMove( wxMouseEvent& event );
	virtual void OnWorkPanelMouseWheel( wxMouseEvent& event );

	virtual void OnPropertyGridChanged( wxPropertyGridEvent& event );

	virtual void OnExit( wxCloseEvent &event );
private:
	void CloseDocument();
	void NewDocument();
	void SaveDocument();
	void SaveDocumentAs();
	void OpenDocument();

	void Update();
	void Repaint( drawing::IDrawer* drawer );
	void PaintGrid( drawing::IDrawer* drawer );
	void PaintMouse( drawing::IDrawer* drawer );

	void ActivateTool();
	void DeactivateTool();

	void UpdateMouse( wxMouseEvent& event );
	void UpdateKeyboard( wxKeyEvent& event );

private:
	wxFileDialog* m_openFileDialog;
	wxFileDialog* m_saveFileDialog;

	PropertyGridEntityViewer* m_propertyGridEntityViewer;
	CoordsTransformer m_coordsTransformer;

	BodyDocument* m_document;
	editor_core::ITool* m_tool;

	input::Mouse m_mouse;
	input::Keyboard m_keyboard;
};

enum wxbuildinfoformat {
	short_f, long_f
};

wxString wxbuildinfo( wxbuildinfoformat format );

#endif
